function loadURL (url) {
  var iFrame
  iFrame = document.createElement('iframe')
  iFrame.setAttribute('src', url)
  iFrame.setAttribute('style', 'display:none;')
  iFrame.setAttribute('height', '0px')
  iFrame.setAttribute('width', '0px')
  iFrame.setAttribute('frameborder', '0')
  document.body.appendChild(iFrame)
  // 发起请求后这个iFrame就没用了，所以把它从dom上移除掉
  iFrame.parentNode.removeChild(iFrame)
  iFrame = null
}
// 网页调用APP方法 - ios_wkwebview
function shareClickIos (title, content, url, imgPath, shareStyle) {
  // loadURL('haleyAction://shareClick?title=' + title + ' & content=' + content + ' & url = ' + url + ' & imgPath = ' + imgPath+ ' & shareStyle = ' + shareStyle)
  loadURL('haleyAction://shareClick?title=' + title + '&content=' + content + '&url=' + url + '&imgPath=' + imgPath + '&shareStyle=' + shareStyle)
}
// 网页调用APP方法 - android
function shareClickAndroid (title, content, url, imgPath, shareStyle) {
  nativeMethod.shareClick(title, content, url, imgPath, shareStyle)
}
// 网页调用APP方法 - 分享
// function shareClick (title, content, url, imgPath, shareStyle) {
//   if(nativeMethod){
//     shareClickAndroid(title, content, url, imgPath, shareStyle)
//   } else {
//     shareClickIos(title, content, url, imgPath, shareStyle)
//   }
// }
function shareClick (title, content, url, imgPath, shareStyle) {
  if (typeof nativeMethod !== 'undefined') {
    shareClickAndroid(title, content, url, imgPath, shareStyle)
  } else {
    alert(1)
    shareClickIos(title, content, url, imgPath, shareStyle)
  }
}
export default shareClick
